package com.yx1996.web.servlet;

import com.yx1996.domain.Customer;
import com.yx1996.domain.LinkMan;
import com.yx1996.service.CustomerService;
import com.yx1996.service.LinkManService;
import com.yx1996.serviceimpl.CustomerServiceImpl;
import com.yx1996.serviceimpl.LinkManServiceImpl;
import org.apache.commons.beanutils.BeanUtils;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Map;

public class AddlinkmanServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

         LinkManService lms = new LinkManServiceImpl();
        try {
            LinkMan linkMan = new LinkMan();
            Map<String, String[]> parameterMap = request.getParameterMap();
            BeanUtils.populate(linkMan,parameterMap);
            lms.add(linkMan);
            response.sendRedirect(request.getContextPath()+"/menu.jsp");
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request,response);
    }
}
